package org.mm.proxycache.http.codec;

import static com.google.common.base.Objects.nonNull;

import java.util.Date;

import org.mm.proxycache.http.HttpMethod;
import org.mm.proxycache.http.HttpUrl;
import org.mm.proxycache.http.MutableHttpRequest;

public class DefaultHttpRequest extends DefaultHttpMessage implements MutableHttpRequest
{

    private HttpMethod method;
    private HttpUrl url;
    private final Date date = new Date();

    /*
     * (non-Javadoc)
     * 
     * @see org.mm.proxycache.http.MutableHttpRequest#duplicate()
     */
    public MutableHttpRequest duplicate()
    {
        DefaultHttpRequest request = new DefaultHttpRequest();
        request.version( httpVersion );
        request.headers.putAll( headers );
        request.method( method );
        request.requestUrl( url );
        return request;
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.mm.proxycache.http.MutableHttpRequest#setMethod(org.mm.proxycache.http.HttpMethod)
     */
    public void method( HttpMethod method )
    {
        this.method = nonNull( method );
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.mm.proxycache.http.MutableHttpRequest#setRequestUri(java.lang.String)
     */
    public void requestUrl( HttpUrl url )
    {
        this.url = nonNull( url );
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.mm.proxycache.http.HttpRequest#getMethod()
     */
    public HttpMethod method()
    {
        return method;
    }

    /*
     * (non-Javadoc)
     * 
     * @see org.mm.proxycache.http.HttpRequest#getRequestUri()
     */
    public HttpUrl url()
    {
        return url;
    }

    /* (non-Javadoc)
     * @see org.mm.proxycache.http.HttpRequest#date()
     */
    public Date date()
    {
        return date;
    }

}
